home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-13 | 6.1 KB | 247 lines | [TEXT/MPS ] |
- // UWindoid.h -----------------------------------------------------------------
- // Copyright © 1991 by Apple Computer, Inc. All rights reserved.
-
-
- // INCLUDE FILES --------------------------------------------------------------
-
- #include "IncludeFiles.h"
-
-
- //FORWARD DECLARATIONS --------------------------------------------------------
-
- class TFloatingMenu;
- class TDefaultView;
- class TLightPalette;
-
-
- // GLOBALS --------------------------------------------------------------------
-
- TFloatingMenu* gFloatingMenu;
- TWindow* gFloatMenuWindow;
-
- enum eLights {kGreen=0,kYellow,kRed, kNoTool = 42}; // global values for the lights
-
-
- // CLASS DEFINITIONS-----------------------------------------------------------
-
- // TApplication ---------------------------------------------------------------
-
- DeclareClassDesc(TWindoidApplication);
-
- class TWindoidApplication : public TApplication {
-
- DeclareClass(TWindoidApplication);
-
- public:
- // METHODS
- virtual void IWindoidApplication(OSType itsMainFileType,
- OSType itsCreator);
- virtual void DoSetupMenus();
- virtual TDocument* DoMakeDocument(CommandNumber, TFile* itsFile);
- };
-
-
- // TDocuments -----------------------------------------------------------------
-
- DeclareClassDesc(TWindoidDocument);
-
- class TWindoidDocument : public TDocument {
-
- DeclareClass(TWindoidDocument);
-
- public:
- // METHODS
- virtual void DoMakeViews(Boolean forPrinting);
-
- virtual void DoSetupMenus(); // setup document menus
- virtual void DoMenuCommand(CommandNumber aCommandNumber);
- virtual void DoLight(eLights); // do Light drawing
-
- // FIELDS
- TDefaultView* fView; // the view used
- };
-
-
- // TViews ---------------------------------------------------------------------
-
- DeclareClassDesc(TDefaultView);
-
- class TDefaultView : public TView {
-
- DeclareClass(TDefaultView);
-
- public:
- // ENUMS AND TYPEDEFS
- enum eCoordinate {ktop=20,kbottom=150,kleft=200,kright=250};
-
- // METHODS
- TDefaultView (); // constructor
-
- virtual void Draw(const VRect& area);// general draw method
- virtual void DrawTrafficLight(); // draw traffic light body
- virtual void DrawLight(); // general light drawing method
- virtual void DrawGreen(); // draw green light
- virtual void DrawYellow(); // draw yellow light
- virtual void DrawRed(); // draw red light
-
- // FIELDS
- CRect fTrafficRect; // traffic light components
- CRect fBlackTopRect;
- CRect fTrafficLightFrame;
- CRect fGreenRect;
- CRect fYellowRect;
- CRect fRedRect;
- CStr255 fTitle;
- eLights fCurrentLight;
- };
-
-
- // And now the cool stuff, the TearOff floating window class
-
- DeclareClassDesc(TFloatingMenu);
-
- class TFloatingMenu : public TTearOffMenuView {
-
- DeclareClass(TFloatingMenu);
-
- public:
- // METHODS
- virtual void IFloatingMenu(); // init floating menu
- };
-
-
- DeclareClassDesc(TLightPalette);
-
- class TLightPalette : public TView {
-
- DeclareClass(TLightPalette);
-
- public:
- // METHODS
-
- TLightPalette();
-
- virtual void ILightPalette(TDocument *itsDocument, TView *itsView);
-
- virtual void Draw(const VRect &area); // draw view
- virtual void Activate(Boolean entering); // activate view
-
- virtual void DoMouseCommand (VPoint& theMouse, TToolboxEvent* event,
- CPoint hysteresis);
-
- virtual void TrackFeedback (TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn);
-
-
- virtual void SelectNewTool(eLights whichTool);
- virtual void FrameTool(CRect); // frame the selected tool
- virtual void BuildChoiceArray(); // build tool array
- virtual void Toggle(); // toggle tool selections
- virtual void DoHighlightSelection(HLState fromHL, HLState toHL);
-
- // FIELDS
- CRect fChoiceArray[kLightsInPalette]; // tool array
- eLights fCurrentTool; // tool selection
- eLights fOldTool; // earlier used tool
- eLights fSelectedTool; // currently *selected* tool
- };
-
-
- // TCOMMANDS ------------------------------------------------------------------
-
- DeclareClassDesc(TToolSelectCommand);
-
- class TToolSelectCommand : public TTearOffMenuViewTracker {
-
- DeclareClass(TToolSelectCommand);
-
- public:
- // METHODS
- virtual void IToolSelectCommand (TLightPalette* theToolsPalette,
- TLightPalette* theMenuToolsPalette,
- TLightPalette* theFloatingToolsPalette,
- VPoint& theMouse);
-
- virtual void DoIt(void); // execute selection command
- virtual Boolean IsDoneTracking(); // no more tracking?
-
- virtual void TrackFeedback (TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn);
-
- virtual TTracker* TrackMouse (TrackPhase aTrackPhase,
- VPoint& anchorPoint,
- VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove);
-
- // FIELDS
- eLights fTool; // selected tool
- TLightPalette* fMenuToolsPalette; // ptr to Menu Tool view
- TLightPalette* fFloatingToolsPalette; // ptr to Floating WIndow view
- Boolean fExitTracking; // keep track of tracking state
- };
-
-
- DeclareClassDesc(TTrafficCommand);
-
- class TTrafficCommand : public TCommand {
-
- DeclareClass(TTrafficCommand);
-
- public:
- // METHODS
- TTrafficCommand();
-
- TWindoidDocument* fCommandDocument; // document attached to command
- };
-
-
- DeclareClassDesc(TGreenCommand);
-
- class TGreenCommand : public TTrafficCommand {
-
- DeclareClass(TGreenCommand);
-
- public:
- // METHODS
- virtual void IGreenCommand(TWindoidDocument*);
- virtual void DoIt();
- };
-
-
- DeclareClassDesc(TYellowCommand);
-
- class TYellowCommand : public TTrafficCommand {
-
- DeclareClass(TYellowCommand);
-
- public:
- // METHODS
- virtual void IYellowCommand(TWindoidDocument*);
- virtual void DoIt();
- };
-
-
- DeclareClassDesc(TRedCommand);
-
- class TRedCommand : public TTrafficCommand {
-
- DeclareClass(TRedCommand);
-
- public:
- // METHODS
- virtual void IRedCommand(TWindoidDocument*);
- virtual void DoIt();
- };
-
-
- // THE END -------------------------------------------------------------------
-